package com.gxa.controller.shezhicontroller;

import com.gxa.common.R;
import com.gxa.pojo.ShouRuType;
import com.gxa.pojo.ZhiChuType;
import com.gxa.service.shezhiservice.KeHuType46Service;
import com.gxa.service.shezhiservice.ShouRuType46Service;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;

/**
 * @Author x
 */
@RestController
@RequestMapping("/ShouRuType")
@Api(value = "收入类别管理" , tags = "收入类别数据接口API")
@RequiresPermissions("收入类别")
public class ShouRuTypeController {

    @Autowired(required = false)
    public R r;

    @Autowired(required = false)
    public ShouRuType46Service shouRuType46Service;

    @GetMapping("/selectAllShouRuTypeForPage")
    @ApiOperation(value = "收入查询接口" ,notes = "提供当前页码数与每页显示条数",httpMethod = "get",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "size",value = "每页显示条数", required = true,dataType = "int",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })

    public R selectAllShouRuTypeForPage(@RequestParam int page,@RequestParam int size)
    {
//        r.setCode(200);
//        r.setMsg("查询成功！");
//        ArrayList<Object> list = new ArrayList<>();
//        list.add("jjj");
//        r.setData(list);
//        return r;
        return shouRuType46Service.selectAllShouRuTypeForPage( page , size );
    }
    @GetMapping("selectShouRuTypeByType")
    @ApiOperation(value = "收入查询接口（根据条件查询）",notes="提供当前页码与每页显示条数，收入类别",httpMethod = "get",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "size",value = "每页显示条数", required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "shouRuType",value = "收入类别",required = false,dataType = "int",paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R selectShouRuTypeByType(@RequestParam int page,@RequestParam int size,String shouRuType)
    {
//        r.setCode(200);
//        r.setMsg("查询成功！");
//        ArrayList<Object> list = new ArrayList<>();
//        ShouRuType shouRuType = new ShouRuType();
//        shouRuType.setId(665566);
//        list.add(shouRuType);
//        r.setData(list);
//        return r;
        return shouRuType46Service.selectShouRuTypeByType(page ,size ,shouRuType);
    }
    @PostMapping("/insertShouRuType")
    @ApiOperation(value = "新增收入接口",notes="提供收入信息",httpMethod = "post",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R insertShouRuType(@RequestBody ShouRuType shouRu)
    {
//        r.setCode(200);
//        r.setMsg("查询成功！");
//        ArrayList<Object> list = new ArrayList<>();
//        ShouRuType shouRuType = new ShouRuType();
//        shouRuType.setId(6666);
//        list.add(shouRuType);
//        r.setData(list);
//        return r;
        return shouRuType46Service.insertShouRuType(shouRu);
    }

    @PostMapping("/updateShouRuTypeById")
    @ApiOperation(value = "修改收入信息接口",notes="提供收入信息",httpMethod = "post",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R updateShouRuTypeById(@RequestBody ShouRuType shouRu)
    {
//        r.setCode(200);
//        r.setMsg("修改成功！");
//        ArrayList<Object> list = new ArrayList<>();
//        ShouRuType shouRuType = new ShouRuType();
//        shouRuType.setId(6665556);
//        list.add(shouRuType);
//        r.setData(list);
//        return r;
        return shouRuType46Service.updateShouRuTypeById(shouRu);
    }

    @PostMapping("/deleteShouRuTypeById")
    @ApiOperation(value = "删除收入接口",notes = "提供收入id",httpMethod = "post",response = R.class)
    @ApiImplicitParam(name="id",value = "主键",required = true,dataType = "int")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R deleteShouRuTypeById(@RequestParam int id)
    {
//        r.setCode(200);
//        r.setMsg("删除成功！");
//        ArrayList<Object> list = new ArrayList<>();
//        ShouRuType shouRuType = new ShouRuType();
//        shouRuType.setId(26888);
//        list.add(shouRuType);
//        r.setData(list);
//        return r;
        return shouRuType46Service.deleteShouRuTypeById(id);
    }


}
